/*
 * Copyright (c) 2006 - 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Arrays;

/**
 * <p>Project: app2022 - Exam08
 * <p>Powered by webrx On 2022-01-20 10:59:57
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Exam08 {
    public static void main(String[] args) {
        String u = System.getProperty("user.dir");
        File f = new File(u);
        Arrays.stream(f.listFiles(e -> e.isFile() && e.length() > 1024 * 20 && e.getName().endsWith(".jpg"))).forEach(e -> System.out.println(e.getAbsolutePath()));
    }

    public static void test(String[] args) throws Exception {
        String u = System.getProperty("user.dir");
        File f = new File(u);
        //f.listFiles() File[]
        //f.list() String[]
        File[] fs = f.listFiles(e -> e.isFile() && e.getName().startsWith("p2.jpg."));
        System.out.println(fs.length);
        FileOutputStream fos = new FileOutputStream("wx.jpg");
        for (File t : fs) {
            var fis = new FileInputStream(t);
            fos.write(fis.readAllBytes());
            fis.close();
            t.delete();
        }
        fos.flush();
        fos.close();
    }
}
